<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

require_once JPATH_SITE . '/components/com_mariageplanner/helpers/content.php';

$doc = JFactory::getDocument();
$doc->addStyleSheet("https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/humanity/jquery-ui.css");
$doc->addStyleSheet(JURI::base()."media/system/css/system.css");
$doc->addStyleSheet(JURI::base()."administrator/templates/bluestork/css/template.css");
$doc->addStyleSheet(JURI::base()."components/com_mariageplanner/css/styles.css");

$doc->addScript("https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js");
$doc->addScript("https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js");
$doc->addScript(JURI::base()."components/com_mariageplanner/js/custom.js");

$params = $this->state->get('params');

$doc->addScriptDeclaration('
	jQuery(document).ready(function() {
		jQuery("button").button();
		jQuery("input, textarea, select").addClass("gradient");
		var characterLimit = 70;

		jQuery("#remainingCharacters").html(characterLimit);  
		
		jQuery(\'[name="jform[message]"]\').bind("keyup", function(){  
	        var charactersUsed = jQuery(this).val().length;  
	  
	        if(charactersUsed > characterLimit){  
	            charactersUsed = characterLimit;  
	            jQuery(this).val(jQuery(this).val().substr(0, characterLimit));  
	            jQuery(this).scrollTop(jQuery(this)[0].scrollHeight);  
	        }  
	  
	        var charactersRemaining = characterLimit - charactersUsed;  
	  
	        jQuery("#remainingCharacters").html(charactersRemaining);  
    	}).trigger("keyup");
	});
');

JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
?>
<div id="element-box">
	<div class="m">
		<form action="<?php echo JRoute::_('index.php?option=com_mariageplanner&view=task&id='.(int) $this->item->id); ?>"
		      method="post" name="adminForm" id="layout-form" class="form-validate">
		    <div class="width-100">
			<fieldset class="adminform">
				<legend><?php echo JText::_( 'COM_MARIAGEPLANNER_TASK_DETAILS' ); ?></legend>
				<br/>
				<ul class="adminformlist">
		
		<?php foreach($this->form->getFieldset() as $field): ?>
					<li><div class="clr"></div><?php echo $field->label;echo $field->input;?></li>
					<?php if($field->name=="jform[date]") : ?>
						<script type="text/javascript">
						<!--
							var str = jQuery('[name="jform[date]"]').val().split(' ');
							jQuery('[name="jform[date]"]').val(str[0]);
						//-->
						</script>
					<?php endif; ?>
					
					<?php if($field->name=="jform[message]") : ?> 
					<li><div class='clr'></div><label></label><div>Осталось знаков: <span id='remainingCharacters'></span></div>
					<?php endif; ?>
					
		<?php endforeach; ?>
				<script type="text/javascript">
				<!--
					jQuery('[name="jform[message]"]').attr('placeholder', 'Пожалуйста, введите содержание мероприятия здесь');
					jQuery('[name="jform[mobile]"]').attr('placeholder', 'мобильник без 8').css('padding-left', 2).keyup(function(){ this.value=this.value.replace(/\D*/g, '').substr(0,10); });
					jQuery('[name="jform[date]"]').click(function(){ jQuery('#jform_date_img').trigger('click'); });
					
					/*.before(
							jQuery('<span style="position: absolute; margin: 6px 0px 5px 0px;">+7</span>')
							.css('margin-left', jQuery('#jform_mobile-lbl').width()+5+3)
							.css('font-size', jQuery('#jform_mobile').css('font-size')));*/
				//-->
				</script>
		
				</ul>
				<div class="clr"></div>
			</fieldset>
			</div>
			<div>
				<input type="hidden" name="task" value="task.save" />
				<?php echo JHtml::_('form.token'); ?>
			</div>
			<div class="toolbar">
				<button class="gradient" type="button" onclick="Joomla.submitbutton('task.save')">Сохранить</button>
				<button class="gradient" type="reset">Сброс</button>
				<a href="<?php echo JRoute::_('index.php?option=com_mariageplanner&view=tasks'); ?>"><button class="gradient" type="button">Отмена</button></a>
			</div>
		</form>
	</div>
</div>
